﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcs.Web.out_storage_detail
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtout_storage_id.Text))
			{
				strErr+="出库表ID格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtmaterial_id.Text))
			{
				strErr+="物料表ID格式错误！\\n";	
			}
			if(this.txtmaterial_detail_id.Text.Trim().Length==0)
			{
				strErr+="物料分码不能为空！\\n";	
			}
			if(this.txtuse_projectname.Text.Trim().Length==0)
			{
				strErr+="用到的项目不能为空！\\n";	
			}
			if(this.txtreceive_address.Text.Trim().Length==0)
			{
				strErr+="接收人地址不能为空！\\n";	
			}
			if(this.txtreceive_userName.Text.Trim().Length==0)
			{
				strErr+="接收人姓名不能为空！\\n";	
			}
			if(this.txtreceive_userPhone.Text.Trim().Length==0)
			{
				strErr+="接收人电话不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtreceive_time.Text))
			{
				strErr+="接收时间格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtop_uid.Text))
			{
				strErr+="操作人格式错误！\\n";	
			}
			if(this.txtremark.Text.Trim().Length==0)
			{
				strErr+="备注不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int out_storage_id=int.Parse(this.txtout_storage_id.Text);
			int material_id=int.Parse(this.txtmaterial_id.Text);
			string material_detail_id=this.txtmaterial_detail_id.Text;
			string use_projectname=this.txtuse_projectname.Text;
			string receive_address=this.txtreceive_address.Text;
			string receive_userName=this.txtreceive_userName.Text;
			string receive_userPhone=this.txtreceive_userPhone.Text;
			DateTime receive_time=DateTime.Parse(this.txtreceive_time.Text);
			int op_uid=int.Parse(this.txtop_uid.Text);
			string remark=this.txtremark.Text;

			lcs.Model.out_storage_detail model=new lcs.Model.out_storage_detail();
			model.out_storage_id=out_storage_id;
			model.material_id=material_id;
			model.material_detail_id=material_detail_id;
			model.use_projectname=use_projectname;
			model.receive_address=receive_address;
			model.receive_userName=receive_userName;
			model.receive_userPhone=receive_userPhone;
			model.receive_time=receive_time;
			model.op_uid=op_uid;
			model.remark=remark;

			lcs.BLL.out_storage_detail bll=new lcs.BLL.out_storage_detail();
			bll.Add(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
